home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 (Special) / OC021.iso / Juegos / King of Skeleton / King of Skeleton.swf / scripts / __Packages / Map.as < prev    next >
Encoding:
Text File  |  2006-02-02  |  3.7 KB  |  107 lines

  1. class Map extends MovieClip
  2. {
  3.    var map;
  4.    var player;
  5.    var ia;
  6.    var shad;
  7.    var scale;
  8.    var dx;
  9.    var dy;
  10.    function Map()
  11.    {
  12.       super();
  13.       this.createEmptyMovieClip("map",this.getNextHighestDepth());
  14.       this.map.cacheAsBitmap = true;
  15.       var _loc3_ = this.createEmptyMovieClip("player",this.getNextHighestDepth());
  16.    }
  17.    function initPlayer()
  18.    {
  19.       this.player.lineStyle(2,255,100,false,"none");
  20.       this.player.beginFill(255,100);
  21.       this.player.moveTo(0,-2);
  22.       this.player.lineTo(6,0);
  23.       this.player.lineTo(0,2);
  24.       this.player.lineTo(0,-2);
  25.       this.player.endFill();
  26.       this.player._rotation = this.ia * Trig.rd;
  27.    }
  28.    function drawTrack(track, sx, sy, size)
  29.    {
  30.       if(this.shad)
  31.       {
  32.          var _loc4_ = this.map.getDepth();
  33.          this.map.removeMovieClip();
  34.          this.createEmptyMovieClip("map",_loc4_);
  35.          this.shad.removeMovieClip();
  36.          delete this.scale;
  37.          delete this.dx;
  38.          delete this.dy;
  39.          this._x = 0;
  40.          this._y = 0;
  41.          this._xscale = 100;
  42.          this._yscale = 100;
  43.          this.player._xscale = 100;
  44.          this.player._yscale = 100;
  45.          this.player._x = 0;
  46.          this.player._y = 0;
  47.       }
  48.       var _loc9_ = track[0].x;
  49.       var _loc8_ = track[0].y;
  50.       this.map.lineStyle(2,16777215,100,false,"none");
  51.       this.map.moveTo(track[0].x,track[0].y);
  52.       this.ia = track[0].a;
  53.       var _loc2_ = 0;
  54.       while(_loc2_ < track.length)
  55.       {
  56.          if(track[_loc2_].s)
  57.          {
  58.             _loc9_ += track[_loc2_].l * Math.cos(track[_loc2_].a);
  59.             _loc8_ += track[_loc2_].l * Math.sin(track[_loc2_].a);
  60.             this.map.lineTo(_loc9_,_loc8_);
  61.          }
  62.          else
  63.          {
  64.             _loc4_ = track[_loc2_].d;
  65.             var _loc5_ = track[_loc2_].a + Trig.ra * _loc4_;
  66.             _loc5_ = 0;
  67.             while(_loc5_ <= track[_loc2_].c)
  68.             {
  69.                var _loc7_ = track[_loc2_].cx + track[_loc2_].r * Math.cos(_loc5_ * _loc4_ + track[_loc2_].a - Trig.ra * _loc4_);
  70.                var _loc6_ = track[_loc2_].cy + track[_loc2_].r * Math.sin(_loc5_ * _loc4_ + track[_loc2_].a - Trig.ra * _loc4_);
  71.                this.map.lineTo(_loc7_,_loc6_);
  72.                _loc5_ += 0.05;
  73.             }
  74.             _loc9_ = track[_loc2_].cx + track[_loc2_].r * Math.cos(track[_loc2_].c * _loc4_ + track[_loc2_].a - Trig.ra * _loc4_);
  75.             _loc8_ = track[_loc2_].cy + track[_loc2_].r * Math.sin(track[_loc2_].c * _loc4_ + track[_loc2_].a - Trig.ra * _loc4_);
  76.             this.map.lineTo(_loc9_,_loc8_);
  77.          }
  78.          _loc2_ = _loc2_ + 1;
  79.       }
  80.       this.scale = size / (this._width <= this._height ? this._height : this._width);
  81.       this._xscale *= this.scale;
  82.       this._yscale *= this.scale;
  83.       this.player._xscale /= this.scale;
  84.       this.player._yscale /= this.scale;
  85.       var _loc10_ = this.getBounds(this._parent);
  86.       this.dx = _loc10_.xMin - sx;
  87.       this.dy = _loc10_.yMin - sy;
  88.       this._x -= this.dx;
  89.       this._y -= this.dy;
  90.       this.map.duplicateMovieClip("shad",this.getNextHighestDepth());
  91.       this.player.swapDepths(this.shad);
  92.       this.map.swapDepths(this.shad);
  93.       this.shad._x = 1 / this.scale;
  94.       this.shad._y = 1 / this.scale;
  95.       var _loc11_ = new Color(this.shad);
  96.       _loc11_.setTransform({ra:100,rb:-255,ga:100,gb:-168,ba:100,bb:-131,aa:100,ab:0});
  97.    }
  98.    function drawPlayer(p, a)
  99.    {
  100.       var _loc2_ = new Vector(p.x * this.scale - this.dx,p.y * this.scale - this.dy);
  101.       this.globalToLocal(_loc2_);
  102.       this.player._x = _loc2_.x;
  103.       this.player._y = _loc2_.y;
  104.       this.player._rotation = a * Trig.rd;
  105.    }
  106. }
  107.